home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swaga_c.zip / ARCHIVES.SWG / 0022_Zip File Format.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  8KB  |  182 lines

  1.  
  2. System of Origin : IBM
  3.  
  4. Original author : Phil Katz
  5.  
  6. FILE FORMAT
  7. -----------
  8.  
  9. Files stored in arbitrary order.  Large zipfiles can span multiple
  10. diskette media. 
  11.  
  12.           Local File Header 1 
  13.                     file 1 extra field 
  14.                     file 1 comment 
  15.                file data 1 
  16.           Local File Header 2 
  17.                     file 2 extra field 
  18.                     file 2 comment
  19.                file data 2
  20.           . 
  21.           . 
  22.           . 
  23.           Local File Header n 
  24.                     file n extra field 
  25.                     file n comment 
  26.                file data n 
  27.      Central Directory 
  28.                central extra field
  29.                central comment
  30.           End of Central Directory
  31.                     end comment
  32. EOF
  33.  
  34.  
  35. LOCAL FILE HEADER
  36. -----------------
  37.  
  38. OFFSET LABEL       TYP  VALUE        DESCRIPTION
  39. ------ ----------- ---- ----------- ---------------------------------- 
  40. 00     ZIPLOCSIG   HEX  04034B50    ;Local File Header Signature 
  41. 04     ZIPVER      DW   0000        ;Version needed to extract 
  42. 06     ZIPGENFLG   DW   0000        ;General purpose bit flag 
  43. 08     ZIPMTHD     DW   0000        ;Compression method 
  44. 0A     ZIPTIME     DW   0000        ;Last mod file time (MS-DOS) 
  45. 0C     ZIPDATE     DW   0000        ;Last mod file date (MS-DOS) 
  46. 0E     ZIPCRC      HEX  00000000    ;CRC-32
  47. 12     ZIPSIZE     HEX  00000000    ;Compressed size 
  48. 16     ZIPUNCMP    HEX  00000000    ;Uncompressed size
  49. 1A     ZIPFNLN     DW   0000        ;Filename length
  50. 1C     ZIPXTRALN   DW   0000        ;Extra field length 
  51. 1E     ZIPNAME     DS   ZIPFNLN     ;filename 
  52. --     ZIPXTRA     DS   ZIPXTRALN   ;extra field 
  53.  
  54. CENTRAL DIRECTORY STRUCTURE
  55. --------------------------- 
  56.  
  57. OFFSET LABEL       TYP  VALUE        DESCRIPTION
  58. ------ ----------- ---- ----------- ----------------------------------
  59. 00     ZIPCENSIG   HEX  02014B50    ;Central file header signature 
  60. 04     ZIPCVER     DB   00          ;Version made by 
  61. 05     ZIPCOS      DB   00          ;Host operating system 
  62. 06     ZIPCVXT     DB   00          ;Version needed to extract 
  63. 07     ZIPCEXOS    DB   00          ;O/S of version needed for extraction 
  64. 08     ZIPCFLG     DW   0000        ;General purpose bit flag 
  65. 0A     ZIPCMTHD    DW   0000        ;Compression method 
  66. 0C     ZIPCTIM     DW   0000        ;Last mod file time (MS-DOS)
  67. 0E     ZIPCDAT     DW   0000        ;Last mod file date (MS-DOS) 
  68. 10     ZIPCCRC     HEX  00000000    ;CRC-32
  69. 14     ZIPCSIZ     HEX  00000000    ;Compressed size
  70. 18     ZIPCUNC     HEX  00000000    ;Uncompressed size 
  71. 1C     ZIPCFNL     DW   0000        ;Filename length 
  72. 1E     ZIPCXTL     DW   0000        ;Extra field length 
  73. 20     ZIPCCML     DW   0000        ;File comment length 
  74. 22     ZIPDSK      DW   0000        ;Disk number start
  75. 24     ZIPINT      DW   0000        ;Internal file attributes 
  76.  
  77.        LABEL       BIT        DESCRIPTION
  78.        ----------- --------- -----------------------------------------
  79.        ZIPINT         0       if = 1, file is apparently an ASCII or 
  80.                               text file 
  81.                       0       if = 0, file apparently contains binary 
  82.                               data 
  83.  
  84.                      1-7      unused in version 1.0.
  85.  
  86. 26     ZIPEXT      HEX  00000000    ;External file attributes, host 
  87.                                     ;system dependent
  88. 2A     ZIPOFST     HEX  00000000    ;Relative offset of local header 
  89.                                     ;from the start of the first disk 
  90.                                     ;on which this file appears
  91. 2E     ZIPCFN      DS   ZIPCFNL     ;Filename or path - should not 
  92.                                     ;contain a drive or device letter, 
  93.                                     ;or a leading slash. All slashes 
  94.                                     ;should be forward slashes '/' 
  95. --     ZIPCXTR     DS   ZIPCXTL     ;extra field
  96. --     ZIPCOM      DS   ZIPCCML     ;file comment
  97.  
  98.  
  99. END OF CENTRAL DIR STRUCTURE
  100. ---------------------------- 
  101.  
  102. OFFSET LABEL       TYP  VALUE        DESCRIPTION 
  103. ------ ----------- ---- ----------- ---------------------------------- 
  104. 00     ZIPESIG     HEX  06064B50    ;End of central dir signature
  105. 04     ZIPEDSK     DW   0000        ;Number of this disk 
  106. 06     ZIPECEN     DW   0000        ;Number of disk with start central dir 
  107. 08     ZIPENUM     DW   0000        ;Total number of entries in central dir 
  108.                                     ;on this disk 
  109. 0A     ZIPECENN    DW   0000        ;total number entries in central dir 
  110. 0C     ZIPECSZ     HEX  00000000    ;Size of the central directory
  111. 10     ZIPEOFST    HEX  00000000    ;Offset of start of central directory 
  112.                                     ;with respect to the starting disk
  113.                                     ;number 
  114. 14     ZIPECOML    DW   0000        ;zipfile comment length 
  115. 16     ZIPECOM     DS   ZIPECOML    ;zipfile comment
  116.  
  117.  
  118. ZIP VALUES LEGEND
  119. -----------------
  120.  
  121.        HOST O/S 
  122.  
  123.        VALUE  DESCRIPTION               VALUE  DESCRIPTION 
  124.        ----- -------------------------- ----- ------------------------
  125.        0      MS-DOS and OS/2 (FAT)     5      Atari ST 
  126.        1      Amiga                     6      OS/2 1.2 extended file sys 
  127.        2      VMS                       7      Macintosh 
  128.        3      *nix                      8 thru 
  129.        4      VM/CMS                    255    unused 
  130.  
  131.  
  132.        GENERAL PURPOSE BIT FLAG 
  133.  
  134.        LABEL       BIT        DESCRIPTION 
  135.        ----------- --------- -----------------------------------------
  136.        ZIPGENFLG      0       If set, file is encrypted 
  137.           or          1       If file Imploded and this bit is set, 8K 
  138.        ZIPCFLG                sliding dictionary was used. If clear, 4K
  139.                               sliding dictionary was used.
  140.                       2       If file Imploded and this bit is set, 3 
  141.                               Shannon-Fano trees were used. If clear, 2 
  142.                               Shannon-Fano trees were used. 
  143.                      3-4      unused 
  144.                      5-7      used internaly by ZIP
  145.  
  146.        Note:  Bits 1 and 2 are undefined if the compression method is 
  147.               other than type 6 (Imploding). 
  148.  
  149.  
  150.        COMPRESSION METHOD
  151.  
  152.        NAME        METHOD  DESCRIPTION 
  153.        ----------- ------ -------------------------------------------- 
  154.        Stored         0    No compression used 
  155.        Shrunk         1    LZW, 8K buffer, 9-13 bits with partial clearing 
  156.        Reduced-1      2    Probalistic compression, L(X) = lower 7 bits 
  157.        Reduced-2      3    Probalistic compression, L(X) = lower 6 bits 
  158.        Reduced-3      4    Probalistic compression, L(X) = lower 5 bits 
  159.        Reduced-4      5    Probalistic compression, L(X) = lower 4 bits
  160.        Imploded       6    2 Shanno-Fano trees, 4K sliding dictionary
  161.        Imploded       7    3 Shanno-Fano trees, 4K sliding dictionary 
  162.        Imploded       8    2 Shanno-Fano trees, 8K sliding dictionary
  163.        Imploded       9    3 Shanno-Fano trees, 8K sliding dictionary 
  164.  
  165.  
  166.        EXTRA FIELD 
  167.  
  168.        OFFSET LABEL       TYP  VALUE       DESCRIPTION
  169.        ------ ----------- ---- ---------- ----------------------------
  170.        00     EX1ID       DW   0000        ;0-31 reserved by PKWARE
  171.        02     EX1LN       DW   0000
  172.        04     EX1DAT      DS   EX1LN       ;Specific data for individual
  173.        .                                   ;files. Data field should begin
  174.        .                                   ;with a s/w specific unique ID
  175.        EX1LN+4
  176.               EXnID       DW   0000
  177.               EXnLN       DW   0000
  178.  
  179.               EXnDAT      DS   EXnLN       ;entire header may not exceed 64k
  180.  
  181.  
  182.